<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */
?>
<?=$this->header()?>


    <?=$this->menu("images")?>


    <h1><?=$this->message("label.header", _Image::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Image::BUNDLE),
                "href"=>"image/index"
            ),
            array(
                "name"=>($this->imageForm->getTinyImage()->getTinyImageId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE)." \"".$this->imageForm->getTinyImage()->getImageRelatedByThumbnailId()->getBinaryFile()->getFileName()."\"" :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item", _Image::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Image::BUNDLE)?>


    <form id="<?=get_class($this->imageForm)?>"
          action="image/save"
          method="post"
          enctype="multipart/form-data"
          class="uniForm">

        <div>
            <input type="hidden"
                   name="tinyImage->tinyImageId"
                   value="<?=$this->imageForm->getTinyImage()->getTinyImageId()?>" />
            <input type="hidden"
                   name="tinyImage->imageRelatedByImageId->imageId"
                   value="<?=$this->imageForm->getTinyImage()->getImageId()?>" />
            <input type="hidden"
                   name="tinyImage->imageRelatedByImageId->binaryFileId"
                   value="<?=$this->imageForm->getTinyImage()->getImageRelatedByImageId()->getBinaryFileId()?>" />
            <input type="hidden"
                   name="tinyImage->imageRelatedByThumbnailId->imageId"
                   value="<?=$this->imageForm->getTinyImage()->getThumbnailId()?>" />
            <input type="hidden"
                   name="tinyImage->imageRelatedByThumbnailId->binaryFileId"
                   value="<?=$this->imageForm->getTinyImage()->getImageRelatedByThumbnailId()->getBinaryFileId()?>" />
        </div>

        <? if($this->imageForm->getTinyImage()->getTinyImageId() == 0): ?>
            <p><?=$this->message("note.main", _Image::BUNDLE, null, null, false)?></p>
        <? endif; ?>

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("formImage")?>">
                <th><label for="formImage"><?=$this->message("label.item", _Image::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="formImage"
                           id="formImage"
                           value=""
                           type="file"
                           class="textInput" />
                    <p class="hint"><?=$this->message("note.valid", _Image::BUNDLE)?></p>
                </td>
            </tr>

            <? if($this->imageForm->getTinyImage()->getTinyImageId() == 0): ?>

                <tr class="ctrl">
                    <th></th>
                    <th></th>
                    <td><?=$this->message("label.or", _Core::BUNDLE)?></td>
                </tr>

                <tr class="ctrl<?=$this->error("path")?>">
                    <th><label for="path">Directory</label></th>
                    <th class="required"><em>*</em></th>
                    <td>
                        <input name="path"
                               id="path"
                               value="<?=$this->imageForm->getPath()?>"
                               maxlength="255"
                               type="text"
                               class="textInput" />
                        <p class="hint"><?=$this->message("note.directory", _Image::BUNDLE)?></p>
                    </td>
                </tr>

            <? endif; ?>

            <tr class="ctrl<?=$this->error("resize")?>">
                <th><label for="resize"><?=$this->message("prompt.resize", _Image::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <select name="resize"
                            id="resize"
                            class="textInput">
                        <option value="">--</option>
                        <?=$this->settings()->resize($this->imageForm->getResize())?>
                    </select>
                </td>
            </tr>
            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('image/index')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>